package com.limit.exception;

import com.limit.enums.BizCodeEnum;
import lombok.Data;

/**
 * 全局业务异常类(Biz)
 *
 * @Description
 * @Author hbz
 **/

@Data
public class BizException extends RuntimeException {

    private int code;
    private String msg;

    /**
     * 自定义状态码与错误信息
     * @param code
     * @param msg
     */
    public BizException(int code, String msg){
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    /**
     * 异常时传入错误码的枚举
     * @param bizCodeEnum
     */
    public BizException(BizCodeEnum bizCodeEnum){
        super(bizCodeEnum.getMessage());
        this.code = bizCodeEnum.getCode();
        this.msg = bizCodeEnum.getMessage();
    }

}
